<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/static/include/taglib.jsp"%>
<!DOCTYPE html >
<html>
<head>
 <meta name="viewport" content="width=device-width" />
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
 <title>后台管理--模板编辑</title>
 <link href="${ctxStatic}/ligeruilib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css">
 <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet" />
 
 <!-- <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script> -->
 <script src="${ctxStatic}/ligeruilib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
 <script src="${ctxStatic}/layui/layui.all.js"  type="text/javascript"></script>
 <script src="${ctxStatic}/ligeruilib/ligerUI/js/core/base.js" type="text/javascript"></script>
 <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
  <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>

<link href="${ctxStatic}/css/kpiuitanchu.css" rel="stylesheet" />
<style>
.desc {
    color: ActiveCaption;
    border-bottom: 1px solid #d3d3d3;
    margin-top: 3px;
    margin-bottom: 3px;
    font-size:10px;
}
</style>
<script>
$(function(){
    $("#userid").ligerComboBox(
        {
            url: '../common/get_user_list',
            valueField: 'userid',
            textField: 'realname', 
            selectBoxWidth: 441,
            autocomplete: true,
            keySupport: true,
            valueFieldID:"hid",
            onSelected: function(userid,realname){//id为空值，name为选择的值  
              $("#hiduserid").val(userid);
              var data=$("#userid").ligerGetComboBoxManager().getSelected();
              if(data){
            	  $("#szdw").html("实际工作单位："+data.orgname);
                  $("#rsgx").html("人事关系所在单位："+data.rsgxorgname);
              }
              else{
            	  if($("#hiduserid").val()>0){
            		  $("#szdw").html("实际工作单位："+$("#hidorgname").val());
                      $("#rsgx").html("人事关系所在单位："+$("#hidrsgxorgname").val());
                      $("#userid").attr("disabled","disabled");
                      $("#userid").ligerGetComboBoxManager().setDisabled();
            	  }
              }
             
            }, 
            renderItem: function (e)
            { 
                var data = e.data, key = e.key;
                var out = [];
                out.push('<div>' + data.realname + '</div>');
                out.push('<div class="desc">实际工作单位：' + data.orgname + '<font style="margin-left:20px">人事关系所在单位：'+data.rsgxorgname+'</font></div>');
                return out.join('');
            },
            onSuccess:function(data){
            	if($("#hidedituserid").val()>0){
            		$("#userid").ligerGetComboBoxManager().selectValue($("#hiduserid").val());
            	}
            	
            },
            width: 443 
        }
    );
    
    
    
    
    $("#orgid").ligerComboBox({
		valueField : 'orgid',
		textField : 'orgname',
		selectBoxWidth : 441,
		selectBoxHeight:150,
		treeLeafOnly:false,
		valueFieldID:"hid",
		tree: {url : '../common/get_org_list_jd?orgtype=0',
			checkbox: false, 
			nodeWidth:300,
			ajaxType: 'get', 
			idFieldName: 'orgid',
			textFieldName:"orgname",
			idField:"orgid",
        	parentIDField:"orgparentid",
        	onBeforeSelect:function(data){
        		if(data.data.showin==0){
        			return false;
        		}
        		else{
        			return true;
        		}
        		
        	},
			 onSuccess:function(data){
				 if($("#hidorgid").val()>0){
					 $("#orgid").ligerGetComboBoxManager().selectValue($("#hidorgid").val());
				 }
		    	
		    }
		},
		onSelected : function(orgid, orgname) {// id为空值，name为选择的值
			$("#hidorgid").val(orgid);
			
		}
		,width : 443
	});
   
    
})
</script>
</head>
<body>
<div class="tanchucontent" style="width:90%">
   <form class="layui-form" id="formedit" name="formedit" action="add_loanuser" method="post" target="d41d8cd98f00b204e9800998ecf8427e">
    <iframe name="d41d8cd98f00b204e9800998ecf8427e" src="about:blank" style="display:none;"></iframe>
     <table nostyle="true">
      <tr>
       <td class="td_right" >人员：</td>
       <td colspan="3">
         <!--  <select name="userid" lay-verify="required" >
                <c:forEach var="item" items="${userlst}">
                  <option value="${item.userid}">${item.realname} (${item.orgname})</option>
                </c:forEach>
         </select>-->
       
         <input type="text" id="userid" autocomplete="off" lay-verify="ruserid" style="padding-left:10px;" class="layui-input">
         <input type="hidden" id="hiduserid" name="userid" value="${entity.userid }">
       </td>
      </tr>
      <tr>
       <td colspan="2" id="szdw" style="text-align: center"></td>
       <td colspan="2" id="rsgx" style="text-align: center"></td>
      </tr>
      <tr>
       <td class="td_right" >借调部门：</td>
       <td colspan="3">
         <!--  <select name="orgid" lay-verify="required">
                <c:forEach var="item" items="${orglst}">
                  <option value="${item.orgid}">${item.orgname}</option>
                </c:forEach>
         </select>-->
          <input type="text" id="orgid" lay-verify="ruserid" class="layui-input">
         <input type="hidden" id="hidorgid" name="orgid" value="${entity.loanorgid }">
       </td>
      </tr>
      <tr>
       <td class="td_right" >开始时间：</td>
       <td>
         <input type="text" id="begintime" name="begintime" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input" value="<fmt:formatDate value='${entity.begintime}' pattern='yyyy-MM-dd'/>">
       </td>
       <td class="td_right" style="min-width:60px;width:80px">结束时间：</td>
       <td>
         <input type="text" id="endtime" name="endtime" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input" value="<fmt:formatDate value='${entity.endtime}' pattern='yyyy-MM-dd'/>">
       </td>
      </tr>
     
      <tr>
       <td class="td_right" >说明：</td>
       <td colspan="3">
        <textarea class="layui-textarea"  name="loandes" >${entity.loandes }</textarea>
       </td>
      </tr>
      <tr>
       <td style="text-align: center;height:50px" colspan="4">
        <button class="button" lay-submit="" lay-filter="demo1" id="btnsave">保存</button>
		 <input type="button" value="关闭" class="button" onclick="top.CloseOpenWindow()"/>
       </td>
      </tr>
     </table>
     
      
  
     
     <input type="hidden" id="loanid" name="loanid" value="${entity.loanid }">
   
     </form>
     <input type="hidden" id="hidorgname" name="orgname" value="${entity.orgname }">
     <input type="hidden" id="hidrsgxorgname" name="rsgxorgname" value="${entity.rsgxsorgname }">
     <input type="hidden" id="hidedituserid" name="edituserid" value="${entity.userid }">
  </div>

<script>


var ctxStatic="${ctxStatic}";
var ctx="${ctx}";


layui.use(['form','laydate'], function(){
   var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
   var laydate = layui.laydate;
   laydate.render({
	    elem: '#begintime'
  });
  laydate.render({
	    elem: '#endtime'
  });
  
  form.verify({
	   ruserid: function(value,demo){
	     if(value==''){
	      return '必填项不能为空';
	     }
	     
	     var sele=$("#hiduserid").val();
	     if(sele==''){
		      return '请选择人员';
		 }
	    
	    }})
  
  
   
   form.render();
});  

function CloseDialog(result,msg){
	  top.frames["iframe"].vLoanUser.addresult(result,msg);
}


</script>
</body>
</html>